package com.huawei.gamebox.service.welfare.gift.card;

import android.content.Context;
import android.os.Handler;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.gamebox.service.common.cardkit.card.BaseGsCard;
import com.huawei.gamebox.service.welfare.gift.bean.RankingCardBean;
import java.lang.ref.WeakReference;
import o.azb;
import o.AccountBussinessListener;
import o.ccp;
import o.cgy;
import o.cgz;
import o.eod;
import o.eoj;
import o.evx;
import o.exp$a;
import o.exp$f;
import o.exp.d;

public class RankingCard extends BaseGsCard {
    private Handler ˊ = new Handler();
    private LinearLayout ˋ;
    private TextView ˎ;
    private TextView ˏ;
    private TextView ॱ;

    class c implements Runnable {
        final /* synthetic */ RankingCard ˋ;

        private c(RankingCard rankingCard) {
            this.ˋ = rankingCard;
        }

        public void run() {
            this.ˋ.ˏ.setVisibility(0);
            this.ˋ.ˎ.setVisibility(8);
        }
    }

    static class e implements AccountBussinessListener {
        private WeakReference<RankingCard> ˋ;

        e(RankingCard rankingCard) {
            this.ˋ = new WeakReference(rankingCard);
        }

        public void onAccountBusinessResult(ccp o_ccp) {
            if (102 == o_ccp.ˎ) {
                RankingCard rankingCard = (RankingCard) this.ˋ.get();
                if (rankingCard != null) {
                    rankingCard.ˋ();
                }
            }
            eoj.ˋ().ˊ("RankingCard");
        }
    }

    public RankingCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        this.ॱ = (TextView) view.findViewById(d.ˈॱ);
        this.ˏ = (TextView) view.findViewById(d.ˊʼ);
        this.ˎ = (TextView) view.findViewById(d.ˋʼ);
        this.ˋ = (LinearLayout) view.findViewById(d.ʼˊ);
        LinearLayout linearLayout = (LinearLayout) view.findViewById(d.ˎ);
        linearLayout.setMinimumHeight(this.ʼॱ.getResources().getDimensionPixelSize(exp$a.ˊᐝ));
        linearLayout.setPaddingRelative(linearLayout.getPaddingStart(), linearLayout.getPaddingTop(), linearLayout.getPaddingEnd(), 0);
        return this;
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof RankingCardBean) {
            RankingCardBean rankingCardBean = (RankingCardBean) cardBean;
            if (!cgy.ˎ(rankingCardBean.ॱॱ())) {
                this.ˏ.setTag(rankingCardBean);
                this.ˏ.setOnClickListener(new evx(this) {
                    final /* synthetic */ RankingCard ॱ;

                    {
                        this.ॱ = r1;
                    }

                    public void ˋ(View view) {
                        this.ॱ.ʽ().onClick(this.ॱ.ˏ);
                    }
                });
            }
            if (UserSession.getInstance().isLoginSuccessful()) {
                ॱ(rankingCardBean);
                ˊ(this.ॱ, this.ˏ, this.ˋ);
                return;
            }
            ˊ();
            ˊ(this.ॱ, this.ˎ, this.ˋ);
        }
    }

    private void ॱ(RankingCardBean rankingCardBean) {
        if (rankingCardBean.ˊ() > 0) {
            this.ॱ.setText(this.ʼॱ.getResources().getString(exp$f.ˋˊ, new Object[]{Integer.valueOf(rankingCardBean.ˊ())}));
        } else {
            this.ॱ.setText(this.ʼॱ.getResources().getString(exp$f.ˊᐝ));
        }
        if (cgy.ˎ(rankingCardBean.ॱॱ())) {
            this.ˏ.setVisibility(8);
        } else {
            this.ˏ.setVisibility(0);
        }
        this.ˎ.setVisibility(8);
    }

    private void ˊ() {
        this.ॱ.setText(this.ʼॱ.getResources().getString(exp$f.ˊˋ));
        this.ˏ.setVisibility(8);
        this.ˎ.setVisibility(0);
        this.ˎ.setOnClickListener(new evx(this) {
            final /* synthetic */ RankingCard ˊ;

            {
                this.ˊ = r1;
            }

            public void ˋ(View view) {
                eoj.ˋ().ˎ("RankingCard", new e(this.ˊ));
                eod.ॱ(this.ˊ.ʼॱ);
            }
        });
    }

    private void ˋ() {
        this.ˊ.post(new c());
    }

    private void ˊ(TextView textView, TextView textView2, LinearLayout linearLayout) {
        int ॱ = (azb.ॱ(this.ʼॱ) - (this.ʼॱ.getResources().getDimensionPixelSize(exp$a.ʿ) * 2)) - this.ʼॱ.getResources().getDimensionPixelSize(exp$a.ʽॱ);
        int i = (int) (((float) ॱ) * 0.6666667f);
        int ॱ2 = ॱ(textView, textView.getText().toString());
        int i2 = 0;
        if (i > ॱ2) {
            i2 = i - ॱ2;
        }
        int i3 = ॱ - i;
        ॱ = ॱ(textView2, textView2.getText().toString());
        if (ॱ <= i3 || i2 <= 0) {
            if (ॱ <= i3) {
                linearLayout.getLayoutParams().width = i3;
            }
            i2 = ॱ;
            ॱ = i;
        } else {
            int i4 = ॱ - i3;
            if (i4 > i2) {
                i2 += i3;
                ॱ = ॱ2;
            } else {
                int i5 = ॱ;
                ॱ = i - i4;
                i2 = i5;
            }
        }
        textView.setWidth(ॱ);
        textView2.setWidth(i2);
    }

    private int ॱ(TextView textView, String str) {
        if (textView == null || cgy.ˎ(str)) {
            return 0;
        }
        return (((int) textView.getPaint().measureText(str)) + textView.getPaddingLeft()) + textView.getPaddingRight();
    }
}
